"""
import os
def fun( path ):
    for root, dirs, files in os.walk( path ):
        for fn in files:
            print(root, fn)
s=fun(r"E:\\python作业\\第1阶段保底版作业素材\\task")#遍历文件夹内的文件名
"""
import os
#作业指定的文本储存在E:\python作业\第1阶段保底版作业素材\task内
#查找txt文本所在指定的文件夹

all_txtfilesname = os.listdir('E:\\python作业\\第1阶段保底版作业素材\\task')

for one_txtfilename in all_txtfilesname:

    #遍历所有txt文件名并依次读取

    file = open('E:\\python作业\\第1阶段保底版作业素材\\task\\' + one_txtfilename) 
    all_txt_string = file.read()
    all_txt = list(all_txt_string)
    
    #获得txt文本长度

    Len = len(all_txt)

    #遍历每个字符并删除数字字符

    for i in range(0, Len):
        if all_txt[i] == '9':
            all_txt[i] = all_txt[i].replace('9' , '')
            
        elif all_txt[i] == '8':
            all_txt[i] = all_txt[i].replace('8' , '')

        elif all_txt[i] == '7':
            all_txt[i] = all_txt[i].replace('7' , '')

        elif all_txt[i] == '6':
            all_txt[i] = all_txt[i].replace('6' , '')

        elif all_txt[i] == '5':
            all_txt[i] = all_txt[i].replace('5' , '')
            
        elif all_txt[i] == '4':
            all_txt[i] = all_txt[i].replace('4' , '')
            
        elif all_txt[i] == '3':
            all_txt[i] = all_txt[i].replace('3' , '')

        elif all_txt[i] == '2':
            all_txt[i] = all_txt[i].replace('2' , '')

        elif all_txt[i] == '1':
            all_txt[i] = all_txt[i].replace('1' , '')

        elif all_txt[i] == '0':
            all_txt[i] = all_txt[i].replace('0' , '')

    #将改后的文档以同名文件保存到其他目录下

    file_finsh = open('E:\\python作业\\第1阶段保底版作业素材\\去除数字后的txt文件'+ one_txtfilename, 'a')
    for j in range(0, Len):
      file_finsh.write(str(all_txt[j]))
    file_finsh.close()
